package com.ludum.game.rendering;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.TextureRegion;

public class TextureManager {
	private static TextureManager instance = null;
	
	private enum textureEnum {
		BACKGROUND, PLAYER, BLOCK
	}		
	
	private TextureRegion[] images;
	
	private TextureManager(){

		images = new TextureRegion[textureEnum.values().length];
		
		Texture texture = new Texture("texture_sheet.png");

		
		images[textureEnum.BACKGROUND.ordinal()] =
				new TextureRegion(texture, 0, 0, 64, 64);
		images[textureEnum.PLAYER.ordinal()] =
				new TextureRegion(texture, 64, 0, 32, 64);
		images[textureEnum.BLOCK.ordinal()] =
				new TextureRegion(texture, 96, 0, 128, 64);
	}
	
	public static TextureManager getInstance(){
		if(instance == null){
			instance = new TextureManager();	
		}
		return instance;
	}
	
	public TextureRegion backgroundTexture(int frameId) {		
		return images[textureEnum.BACKGROUND.ordinal()];
	}
	
	public TextureRegion playerTexture(int frameId) {
		return images[textureEnum.PLAYER.ordinal()];
	}
	
	public TextureRegion blockTexture(int frameId) {
		return images[textureEnum.BLOCK.ordinal()];
	}
}
